package cn.dada.dadarecipes.mall.product.controller;

import cn.dada.dadarecipes.base.response.JsonResult;
import cn.dada.dadarecipes.mall.product.pojo.dto.ProductQuery;
import cn.dada.dadarecipes.mall.product.pojo.vo.ProductVO;
import cn.dada.dadarecipes.mall.product.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "03.01商城商品模块")
@Slf4j
@RestController
@RequestMapping("/v1/product/")
public class ProductController {

    @Autowired
    ProductService productService;

    @ApiOperation(value = "商品列表查询功能")
    @GetMapping("selectProductList")
    public JsonResult selectProductList(ProductQuery productQuery){
        log.debug("商城商品列表查询：productQuery={}",productQuery);
        List<ProductVO> list = productService.selectProductList(productQuery);
        return JsonResult.ok(list);
    }

    @ApiOperation(value = "商品查询功能")
    @GetMapping("selectProduct/{productId}")
    public JsonResult selectProduct(@PathVariable Long productId){
        log.debug("商城商品列表查询：productId={}",productId);
        ProductVO productVO = productService.selectProduct(productId);
        return JsonResult.ok(productVO);
    }


}
